home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / TRACK.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  963b  |  53 lines

  1. /*    SCCS Id: @(#)track.c    3.0    87/08/08
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4. /* track.c - version 1.0.2 */
  5.  
  6. #include "hack.h"
  7.  
  8. #define    UTSZ    50
  9.  
  10. STATIC_VAR int NEARDATA utcnt, NEARDATA utpnt;
  11. STATIC_VAR coord NEARDATA utrack[UTSZ];
  12.  
  13. #ifdef OVLB
  14. void
  15. initrack(){
  16.     utcnt = utpnt = 0;
  17. }
  18. #endif /* OVLB */
  19.  
  20. #ifdef OVL1
  21.  
  22. /* add to track */
  23. void
  24. settrack(){
  25.     if(utcnt < UTSZ) utcnt++;
  26.     if(utpnt == UTSZ) utpnt = 0;
  27.     utrack[utpnt].x = u.ux;
  28.     utrack[utpnt].y = u.uy;
  29.     utpnt++;
  30. }
  31.  
  32. #endif /* OVL1 */
  33. #ifdef OVL0
  34.  
  35. coord *
  36. gettrack(x, y)
  37. register int x, y;
  38. {
  39.     register int i, cnt, ndist;
  40.     coord tc;
  41.     cnt = utcnt;
  42.     for(i = utpnt-1; cnt--; i--){
  43.         if(i == -1) i = UTSZ-1;
  44.         tc = utrack[i];
  45.         ndist = dist2(x,y,tc.x,tc.y);
  46.         if(ndist < 3)
  47.             return(ndist ? (coord *)&(utrack[i]) : 0);
  48.     }
  49.     return (coord *)0;
  50. }
  51.  
  52. #endif /* OVL0 */
  53.